<!DOCTYPE html>

<html>
<head>
    <meta charset="UTF-8">
    <title>傻强物流信息管理系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/assets/js/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/assets/css/login.css"/>
</head>

<body class="beg-login-bg">
<div class="beg-login-box">
    <header>
        <h1>系统登录</h1>
    </header>
    <div class="beg-login-main">
        <form action="" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="beg-login-icon">
                    <i class="layui-icon">&#xe612;</i>
                </label>
                <input type="text" name="loginName" lay-verify="loginName" autocomplete="off" value="admin1"
                       placeholder="这里输入登录名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="beg-login-icon">
                    <i class="layui-icon">&#xe642;</i>
                </label>
                <input type="password" name="password" lay-verify="password" autocomplete="off" value="138002"
                       placeholder="这里输入密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <div class="beg-pull-left beg-login-remember">
                    <label>记住帐号？</label>
                    <input type="checkbox" name="rememerMe" value="true" lay-skin="switch" checked title="记住帐号">
                </div>
                <div class="beg-pull-right">
                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="login">
                        <i class="layui-icon">&#xe650;</i> 登录
                    </button>
                </div>
                <div class="beg-clear"></div>
            </div>
        </form>
    </div>
    <footer>
        <p>版权所有 傻强 © www.oneplatform.com</p>
    </footer>
</div>
<script type="text/javascript" src="/assets/js/layui/layui.js"></script>
<script>
    layui.config({
        version: '20180325',
        base: '/assets/js/'
    });
    layui.use(['layer', 'form', 'oneplatform'], function () {
        var layer = layui.layer,
            $ = layui.jquery,
            oneplatform = layui.oneplatform,
            form = layui.form;

        form.on('submit(login)', function (data) {
            var loading = layer.load();
            $.ajax({
                dataType: "json",
                type: "POST",
                url: 'user/login',
                contentType: "application/json",
                data: JSON.stringify(data.field),
                complete: function () {
                    layer.close(loading);
                },
                success: function (data) {
                    if (data.code == 200) {
                        oneplatform.success('登录成功');
                        setTimeout(function () {
                            window.location.href = '/index.html';
                        }, 500);
                    } else {
                        oneplatform.error(data.msg);
                    }
                },
                error: function (xhr, type) {
                    oneplatform.error('系统错误');
                }
            });
            return false;
        });
    });
</script>
</body>

</html>